<template>
	<view class="u-page">
		<u-row customStyle="margin-bottom: 10px">
			<u-col span="6">
				<u--text suffixIcon="arrow-down" @click="show=true" iconStyle="font-size: 20px" :bold="true"
					align="center" mode="date" :text="currentdate"></u--text>
			</u-col>
			<u-col span="6">
				<u-line direction="col">
				</u-line>
	<!-- 			<u--text suffixIcon="arrow-down" iconStyle="font-size: 18px" :bold="true" align="center" text="工程筛选"
					@click='showBuildFilter=true'>
				</u--text> -->

			</u-col>

		</u-row>
		<u-calendar :show="show" minDate='2022-10-1' maxDate="2024-12-1" monthNum='48' :mode="'single'"
			@close="show=false" @confirm="confirm" :closeOnClickOverlay="true">
		</u-calendar>
		<u-popup :show="showBuildFilter" mode="top" @close="showBuildFilter=false" @open="showBuildFilter=true">
			<u--form labelPosition="left" labelWidth="100">
				<u-form-item label="工程名称" prop="parameters[0].fieldValue" borderBottom ref="item1">
					<u--input v-model="parameters[0].fieldValue" border="none" placeholder="工程名称"></u--input>
				</u-form-item>
				<u-form-item label="工程编号" prop="parameters[1].fieldValue" borderBottom ref="item1">
					<u--input v-model="parameters[1].fieldValue" borderBottom placeholder="工程编号"
						border="none"></u--input>
					<!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
				<u-form-item label="施工负责人" prop="parameters[2].fieldValue" borderBottom ref="item1">
					<u--input v-model="parameters[2].fieldValue" borderBottom placeholder="施工负责人"
						border="none"></u--input>
					<!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
				</u-form-item>
			</u--form>
			<u-button type="primary" text="查找"
				@click="currentpage=1; buildlistshow=[];init();showBuildFilter=false"></u-button>
		</u-popup>
		<u-subsection :list="list" mode="subsection" :current="current1" @change="change1"></u-subsection>
		<u-cell-group>
			<u-cell v-for="(build,index) in showingdata"
			    size="large"
			    :title="build.Name"
			    :label="build.ProjManager"
			    isLink
			></u-cell>

		</u-cell-group>
		<u-loading-page :loading="loading"  bg-color='rgba(0, 0, 0, 0.3)'></u-loading-page>
	</view>
</template>

<script>
	import {
		NotByDay,
	} from '@/common/api.js'
	export default {
		data() {
			return {
				showBuildFilter:false,
				loading:false,
				current1: 0,
				show: false,
				parameters: [{
					fieldName: "Name",
					fieldValue: "",
					conditionalType: "Like"
				}, {
					fieldName: "No",
					fieldValue: "",
					conditionalType: "Like"
				},  {
					fieldName: "ProjManager",
					fieldValue: "",
					conditionalType: "Like"
				},],
				list: ['安全交底未上报', '工程日志未上报', '未检查'],
				// 或者如下，也可以配置keyName参数修改对象键名
				// list: [{name: '未付款'}, {name: '待评价'}, {name: '已付款'}],
				// current: 1,
				currentdate: this.getNowFormatDate(),
				data:{},
				showingdata:[],
				table:["notsafe","notdaily","notcheck"]
			}
		},
		onLoad(options) {
			if(options.targetdate!=='')
			this.currentdate = options.targetdate
		},
		onShow()
		{
			
			this.init()
		},
		methods: {
			init()
			{
				this.loading=true
				NotByDay(this.currentdate).then(res=>{
					this.loading=false
					this.data=res
					this.showingdata = this.data['notsafe']
				})
			},
			confirm(e) {
				this.currentdate = e[0]
				this.show = false
				this.init()
			
			},
			change1(index) {
				this.current1 = index
				this.showingdata = this.data[this.table[this.current1]]
			},
			getNowFormatDate() {
				var date = new Date();

				var year = date.getFullYear();
				var month = date.getMonth() + 1;
				var d = date.getDate();
				var hour = date.getHours();
				var minute = date.getMinutes();
				var second = date.getSeconds();

				if (month < 10) {
					month = "0" + month;
				}

				if (d < 10) {
					d = "0" + d;
				}

				if (hour < 10) {
					hour = "0" + hour;
				}

				if (minute < 10) {
					minute = "0" + hour;
				}

				if (second < 10) {
					second = "0" + second;
				}

				return year + "-" + month + "-" + d //+ " " +hour + ":" + minute + ":" + second;
			},
		}
	}
</script>

<style>

</style>